package com.shioirikukuri.common.exception;

import com.shioirikukuri.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by  shioirikukuri
 */
public class CommonControllerAdvice {
	@ExceptionHandler(BusinessException.class)
	@ResponseBody
	public Result handleBusinessException(BusinessException ex){
		return Result.error(500, ex.getMessage());
	}
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Result handleDefaultException(Exception ex){
		ex.printStackTrace();//在控制台打印错误消息.
		return Result.error( 500, ex.getMessage());
	}
}
